/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-08-01 16:11:48
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2024-08-07 14:12:27
 * @FilePath: \dwys_web\assets\script\ui\Shops.ts
    reset(): void {
        throw new Error('Method not implemented.');
    }pt\ui\Shops.ts
 * @Description: 
 */
import { _decorator, Component, Node } from 'cc';
import { CCComp } from '../../../extensions/oops-plugin-framework/assets/module/common/CCComp';
import { Prefab } from 'cc';
import { instantiate } from 'cc';
import { Shop } from './shop/Shop';
import { oops } from '../../../extensions/oops-plugin-framework/assets/core/Oops';
import * as proto from "../phoenix/protoc/ts/proto_app.js";
import { GameEvent } from '../common/event/GameEvent';
const { ccclass, property } = _decorator;

@ccclass('Shops')
export class Shops extends CCComp {

    @property(Prefab)
    shopPrefab: Prefab|undefined = undefined;

    reset(): void {
        throw new Error('Method not implemented.');
    }

    start() {
        oops.message.on(GameEvent.AddShop, this.onAddShop, this)
    }

    protected onDestroy(): void {
        oops.message.off(GameEvent.AddShop, this.onAddShop, this)
    }

    update(deltaTime: number) {
        
    }

    onAddShop(evnet:string, shop:proto.Iroom_info){
        let shopNode = instantiate(this.shopPrefab!);
        this.node.addChild(shopNode);
        shopNode.getComponent(Shop)!.InitShop(shop);
    }
}


